import request from '@/utils/request'

/**
 * 文章 - 文章详情接口
 * @returns Promise 对象
 */
export const articleDetailAPI = (id) => request({
  url: '/v1_0/articles/' + id
})

/**
   * 文章 - 关注作者接口
   * @returns Promise 对象
   */
export const userFollowingsAPI = (target) => request({
  url: '/v1_0/user/followings',
  method: 'POST',
  data: {
    target
  }
})

/**
   * 文章 - 取关作者接口
   * @returns Promise 对象
   */
export const deleteUserFollowingsAPI = (id) => request({
  url: '/v1_0/user/followings/' + id,
  method: 'DELETE'
})

/**
   * 文章 - 点赞接口
   * @returns Promise 对象
   */
export const articleLikingsAPI = (target) => request({
  url: '/v1_0/article/likings',
  method: 'POST',
  data: {
    target
  }
})

/**
   * 文章 - 取消点赞接口
   * @returns Promise 对象
   */
export const deleteArticleLikingsAPI = (id) => request({
  url: '/v1_0/article/likings/' + id,
  method: 'DELETE'
})

/**
   * 评论 - 获取文章评论列表接口
   * @returns Promise 对象
   */
export const getCommentsAPI = (obj) => request({
  url: '/v1_0/comments',
  params: {
    type: 'a',
    ...obj
  }
})

/**
   * 评论 - 点赞接口
   * @returns Promise 对象
   */
export const commentsLikingAPI = (target) => request({
  url: '/v1_0/comment/likings',
  method: 'POST',
  data: {
    target
  }
})

/**
   * 评论 - 取消点赞接口
   * @returns Promise 对象
   */
export const deleteCommentsLikingAPI = (id) => request({
  url: '/v1_0/comment/likings/' + id,
  method: 'DELETE'
})

/**
   * 评论 - 增加文章评论接口
   * @returns Promise 对象
   */
export const addCommentAPI = (obj) => request({
  url: '/v1_0/comments',
  method: 'POST',
  data: {
    ...obj
  }
})
